﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using WQDSkin.Forms.Controls.Help;

namespace WQDSkin.Forms.Controls
{
    public class WQDBaseButton : Button
    {

        public WQDBaseButton()
        {
           
        }


        #region 自定義

        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            this.SetOverBrush();

            ButtonHelp.SetMouseOverForeground(this, new SolidColorBrush(Colors.White));
        }

        public CornerRadius CornerRadius
        {
            get { return (CornerRadius)GetValue(CornerRadiusProperty); }
            set { SetValue(CornerRadiusProperty, value); }
        }
        public static readonly DependencyProperty CornerRadiusProperty =
            DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(WQDBaseButton), new PropertyMetadata(null));

        [Description("图标"), Category("WQDSkin")]
        public Geometry Icon
        {
            get { return (Geometry)GetValue(IconProperty); }
            set { SetValue(IconProperty, value); }
        }
        public static readonly DependencyProperty IconProperty =
            DependencyProperty.Register("Icon", typeof(Geometry), typeof(WQDBaseButton), new PropertyMetadata(null));

        public double IconWidth
        {
            get { return (double)GetValue(IconWidthProperty); }
            set { SetValue(IconWidthProperty, value); }
        }
        public static readonly DependencyProperty IconWidthProperty =
            DependencyProperty.Register("IconWidth", typeof(double), typeof(WQDBaseButton), new PropertyMetadata(14.0));

        /// <summary>
        /// 图标高度
        /// </summary>
        public double IconHeight
        {
            get { return (double)GetValue(IconHeightProperty); }
            set { SetValue(IconHeightProperty, value); }
        }
        public static readonly DependencyProperty IconHeightProperty =
            DependencyProperty.Register("IconHeight", typeof(double), typeof(WQDBaseButton), new PropertyMetadata(14.0));

        public ControlIcon IconType
        {
            get { return (ControlIcon)GetValue(IconTypeProperty); }
            set
            {
                SetValue(IconTypeProperty, value);
            }
        }

        public static readonly DependencyProperty IconTypeProperty =
            DependencyProperty.Register("IconType", typeof(ControlIcon), typeof(WQDBaseButton),
                new PropertyMetadata(ControlIcon.Not, new PropertyChangedCallback(OnIconTypePropertyChanged))
                );

        private static void OnIconTypePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            WQDBaseButton button = (WQDBaseButton)d;
            ControlIcon icon = (ControlIcon)e.NewValue;
            switch (icon)
            {
                case ControlIcon.Add:
                    button.Icon = WQDSystemPath.Add;
                    button.Foreground = WQDSystemColors.ThemeForeground;
                    button.Background = WQDSystemColors.ThemeBackground;
                    break;
                case ControlIcon.Edit:
                    button.Icon = WQDSystemPath.Edit;
                    button.Foreground = WQDSystemColors.ThemeForeground;
                    button.Background = WQDSystemColors.ThemeSuccess;
                    break;
                case ControlIcon.Delete:
                    button.Icon = WQDSystemPath.Delete;
                    //button.Foreground = WQDSystemColors.ThemeForeground;
                    //button.Background = WQDSystemColors.ThemeDanger;
                    break;
                case ControlIcon.Save:
                    button.Icon = WQDSystemPath.Save;
                    break;
                case ControlIcon.Cancel:
                    button.Icon = WQDSystemPath.Cancel;
                    break;
                case ControlIcon.Refaush:
                    button.Icon = WQDSystemPath.Refaush;
                    //button.Foreground = WQDSystemColors.DefaultForeground;
                    //button.Background = WQDSystemColors.DefaultBackground;
                    break;
                case ControlIcon.Find:
                    button.Icon = WQDSystemPath.Find;
                    break;
                case ControlIcon.Back:
                    button.Icon = WQDSystemPath.Back;
                    break;
                default:
                    button.Icon = null;
                    break;
            }

            switch (icon)
            {
                case ControlIcon.Add: 
                case ControlIcon.Find:
                    //button.Foreground = WQDSystemColors.ThemeForeground;
                    //button.Background = WQDSystemColors.ThemeBackground;
                    break;
            }
        }


        #endregion

    }
}
